<template>
  <div class="container">
    <!-- 顶部返回 -->
    <div class="box"></div>
    <div class="settitle">
      <div class="setimg" @click="$router.back()">
        <img src="../assets/imgs/iconse/左箭头.png" alt="" />
      </div>
      <div class="text"><h2>超级会员</h2></div>
    </div>
    <div class="useritem">
      <div class="userimg">
        <img src="../assets/imgs/头像.jpg" alt="" />
      </div>
      <div class="usertext">
        <p>吃瓜者<i></i></p>
        <span>开通会员享受更多特权</span>
      </div>
    </div>

    <!-- 价格栏目 -->
    <div class="viprice">
      <div class="content">
        <div
          v-for="(item, index) in svipLists"
          :key="item.id"
          :class="['item', flags == item.id ? 'con' : '']"
          @click="pitch(item.id, index)"
        >
          <p>{{ item.name }}</p>
          <div class="price">
            <span><i>￥</i>{{ item.npric }}</span>
            <del>{{ item.opric }}</del>
          </div>
          <div class="pst">
            <span>{{ item.texts }}</span>
          </div>
        </div>
      </div>
    </div>

    <!-- 特权栏目 -->
    <div class="vip-power">
      <div class="power-title">
        <h2>会员权益</h2>
      </div>
      <div class="power-box">
        <div class="power-item" v-for="item in sviplogolist" :key="item.id">
          <div class="power-img">
            <img :src="item.srcs" :alt="item.title" />
          </div>
          <p>{{ item.title }}</p>
          <span>{{ item.texts }}</span>
          <i class="icons" v-if="item.ty">
            <img
              src="../assets/imgs/icons/src_assets_img_me_ic_cv_final_feature.png"
              alt=""
            />
          </i>
        </div>
      </div>
    </div>

    <!-- 会员说明 -->
    <div class="vipexplain">
      <div class="power-title">
        <h2>会员说明</h2>
      </div>
      <div class="powertext">
        <p v-for="item in textlist" :key="item.id">
          {{ item.texts }}
        </p>
      </div>
    </div>

    <div :class="['vipbtn',run?'cons':'']" @click="runFun">
      <span>{{ num }}立即开通</span>
    </div>
    <br>
  </div>
</template>

<script>
import { getSvipJsonData } from "../api/svip.js";
export default {
  data() {
    return {
      svipLists: null,
      sviplogolist: null,
      textlist: null,
      run:false,
      flags: "1",
      num: "99元",
    };
  },
  methods: {
    getSvipListsFun() {
      getSvipJsonData().then((data) => {
        this.svipLists = data.svipLists;
      });
    },
    getSvipLogoListFun() {
      getSvipJsonData().then((data) => {
        this.sviplogolist = data.sviplogolist;
      });
    },
    getTextListpFun() {
      getSvipJsonData().then((data) => {
        this.textlist = data.textlist;
      });
    },
    pitch(id, index) {
      console.log(id);
      this.flags = id;
      this.num = this.svipLists[index].npric;
    },
    runFun(){
    this.$toast("跳转支付页面");
      // this.run=true;
      // setTimeout(()=>{
      //   this.$router.push("/home");
      // },1000)
    }
  },
  created() {
    this.getSvipListsFun();
    this.getSvipLogoListFun();
    this.getTextListpFun();
  },
};
</script>

<style lang="scss" scoped>
.viprice {
  border-bottom: 1px solid #f1f1f1;
  .content {
    display: flex;
    overflow: hidden;
    .item {
      width: 150px;
      margin: 0px 15px;
      height: 180px;
      display: flex;
      align-items: center;
      flex-direction: column;
      justify-content: space-around;
      background-color: #f4f4f4;
      border: 1px solid #f4f4f4;
      font-size: 18px;
      font-weight: 800;
      .price {
        display: flex;
        flex-direction: column;
        color: #f96442;
        font-size: 30px;
        text-align: center;
        span {
          margin-right: 15px;
          margin-bottom: 10px;
          font-weight: 600;
          i {
            font-size: 16px;
          }
        }
        del {
          font-size: 16px;
          color: #9e9794;
          // margin-right: 0px;
        }
      }
      .pst {
        width: 80%;
        height: 25px;
        line-height: 25px;
        font-size: 12px;
        text-align: center;
        background-color: #fee3de;
        border-radius: 10px;
        box-sizing: border-box;
        padding: 2px;
        transform: scale(0.9);
        color: #e9725b;
      }
    }
    .con {
      background-color: #fff5f4;
      border: 1px solid #d0664c;
    }
  }
}

.vip-power {
  margin-top: 50px;
  .power-title {
    h2 {
      height: 35px;
      line-height: 35px;
      font-weight: 800;
      margin-left: 15px;
    }
  }
  .power-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    .power-item {
      width: 30%;
      height: 180px;
      display: flex;
      position: relative;
      flex-direction: column;
      align-items: center;
      justify-content: space-evenly;
      .icons {
        position: absolute;
        width: 30px;
        height: 20px;
        top: 20px;
        right: 20px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .power-img {
        width: 50%;
        img {
          display: block;
          width: 100%;
        }
      }
    }
  }
}

.vipexplain {
  margin: 50px 0px 30px;
  .power-title {
    h2 {
      height: 35px;
      line-height: 35px;
      font-weight: 800;
      margin-left: 15px;
    }
  }
  .powertext {
    margin-top: 20px;
    p {
      height: 25px;
      line-height: 25px;
      font-weight: 800;
      margin-left: 15px;
      font-size: 14px;
      color: #ccc;
    }
  }
}

.vipbtn {
  // width: 100%;
  height: 60px;
  line-height: 60px;
  background-color: #fd6744;
  color: #f2f2f2;
  font-size: 20px;
  margin: 30px;
  text-align: center;
  border-radius: 30px;
}

.cons {
  opacity: 0.5;
  background-color: #e8e8e8;
  color: #666;
  font-weight: 600;
}

.container {
  background-color: #fff;
  .box {
    height: 160px;
    background: url(../assets/imgs/icons/src_assets_img_me_member_vip_bg.png)
      no-repeat top center;
    background-size: 180%;
    opacity: 0.4;
    border-bottom-right-radius: 50% 15px;
    border-bottom-left-radius: 50% 15px;
    overflow: hidden;
  }
  .settitle {
    height: 60px;
    display: flex;
    align-items: center;
    position: relative;
    top: -160px;
    //   box-shadow: 0px 0px 0px 1px rgba($color: #cccc, $alpha: 0.4);
    .setimg {
      height: 26px;
      position: absolute;
      left: 15px;
      img {
        height: 100%;
        display: block;
      }
    }
    .text {
      margin: 0 auto;
      h2 {
        font-size: 26px;
      }
    }
  }
  .useritem {
    position: absolute;
    width: 90%;
    top: 80px;
    left: 0px;
    right: 0px;
    margin: auto;
    height: 120px;
    background: url(../assets/imgs/icons/src_assets_img_me_member_vip_bg.png)
      no-repeat center center;
    background-size: 100%;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 20px 25px;
    .userimg {
      width: 65px;
      height: 65px;
      border-radius: 50%;
      margin-right: 25px;
      overflow: hidden;
      img {
        height: 100%;
        width: 100%;
        display: block;
      }
    }
    .usertext {
      color: #decb91;
      p {
        display: flex;
        align-items: center;
        font-size: 20px;
        // margin-bottom: 10px;
        margin-top: 10px;
        i {
          width: 20px;
          height: 20px;
          display: block;
          background: url(../assets/imgs/icons/src_assets_img_me_ic_not_vip.png)
            no-repeat center center;
          background-size: 100%;
          margin-left: 10px;
        }
      }
      span {
        display: block;
        font-size: 14px;
        height: 30px;
        line-height: 30px;
        margin-top: 10px;
      }
    }
  }
}
</style>